import json
from fastapi import FastAPI
import uvicorn
from pydantic import BaseModel

app = FastAPI()

class Item(BaseModel):
    name: str
    description: str = None
    price: float
    tax: float = None

@app.get("/sentiment")
async def sentiment_analysis(text: str):
    result = text
    print(result)
    return json.dumps(result, ensure_ascii=False)

@app.post("/items/")
async def create_item(item: Item):
    result = {"name": item.name, "price_with_tax": item.price + (item.tax if item.tax else 0)}
    return result


if __name__ == '__main__':
    uvicorn.run(app=app, host='0.0.0.0', port=8802)
